package severlet;

import bean.LeaveReturn;
import dao.LeaveReturnDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.logging.SimpleFormatter;

@WebServlet(name = "StudentLeavereturnServlet", value = "/StudentLeavereturnServlet")
public class StudentLeavereturnServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("utf-8"); // 设置编码格式
        request.setCharacterEncoding("utf-8");


//调用数据库
        LeaveReturnDao leaveReturnDao=new LeaveReturnDao();

//        查询

        String  seessionStu = (String) request.getSession().getAttribute("studentname");
        ArrayList<LeaveReturn>  studentList = leaveReturnDao.getLeaveReturnByStudentname(seessionStu);

        //存放session中
        request.getSession().setAttribute("leavereturn",studentList);
        request.getRequestDispatcher("student_leavereturn.jsp").forward(request,response);
    }
}
